using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Axe.Xml
{
    public sealed class XmlObjSaver<TTargetType> where TTargetType:class
    {
        XmlSerializer m_Serializer = new XmlSerializer(typeof(TTargetType));

        public void Save(TTargetType obj, string fileName)
        {
            using (FileStream fs = new FileStream(fileName,FileMode.Create))
            {
                m_Serializer.Serialize(fs, obj);
            }
        }

        public void Save(TTargetType obj, Stream s)
        {
            m_Serializer.Serialize(s, obj);
        }
    }
}
